package vn.bk.hotel.adapter;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MySQLiteAdapter extends SQLiteOpenHelper {
    
    

    public static final String TABLE_NAME = "favoriteHotel";
    public static final String COLUMN_ID = "_id";
    public static final String COLUMN_NAME= "name";
    public static final String COLUMN_TYPE= "type";
    public static final String COLUMN_ADDRESS = "address";
    public static final String COLUMN_NUMRATE = "numrate";
    public static final String COLUMN_URL_BITMAP = "urlBitmap";
    public static final String COLUMN_LONG = "longitude";
    public static final String COLUMN_LAT = "latitude";
    public static final String COLUMN_PHONE = "phone";
    public static final String COLUMN_URI = "uri";
    public static final String COLUMN_DES = "description";

    public static final String DATABASE_NAME = "hotel.sqlite";
    public static final int DATABASE_VERSION = 1;

    public static String[] columns = {COLUMN_ID,COLUMN_NAME,COLUMN_TYPE,COLUMN_ADDRESS,COLUMN_NUMRATE,
	    COLUMN_URL_BITMAP,COLUMN_LONG,COLUMN_LAT,COLUMN_PHONE,COLUMN_URI,COLUMN_DES};
    // Database creation sql statement
    private static final String DATABASE_CREATE = "create table "
	    + TABLE_NAME + "(" 
	    + COLUMN_ID + " integer primary key autoincrement, "
	    + COLUMN_NAME + " text not null, "
	    + COLUMN_TYPE + " text, "
	    + COLUMN_ADDRESS + " text, "
	    + COLUMN_NUMRATE + " interger,"
	    + COLUMN_URL_BITMAP+" text, "
	    + COLUMN_LONG + " double, "
	    + COLUMN_LAT + " double, "
	    + COLUMN_PHONE + " text, "
	    + COLUMN_URI + " text, "
	    + COLUMN_DES + " text);";

    
    public MySQLiteAdapter(Context context) {
	super(context, DATABASE_NAME, null, DATABASE_VERSION);
	// TODO Auto-generated constructor stub
    }
    
    @Override
    public void onCreate(SQLiteDatabase db) {
	db.execSQL(DATABASE_CREATE);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	// TODO Auto-generated method stub

	db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
	onCreate(db);
    }

}
